package com.mlog.njyjy.ndop.share.sql.config;

import com.mlog.njyjy.ndop.share.sql.support.Model2DdlAuto;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.sql.DataSource;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 * sql ds & orm properties
 * </p>
 *
 * @author <a href="mailto:yingxiufeng@mlogcn.com">alex</a>
 * @version v1.0, 2020/7/8
 */
@ConfigurationProperties(prefix = "mlog")
public class SqlDataSourceProperties {

    /**
     * ds
     */
    private SqlDataSource dataSource;

    /**
     * orm settings
     */
    private SqlOrm orm;

    public SqlDataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(SqlDataSource dataSource) {
        this.dataSource = dataSource;
    }

    public SqlOrm getOrm() {
        return orm;
    }

    public void setOrm(SqlOrm orm) {
        this.orm = orm;
    }

    public static class SqlOrm {

        /**
         * the packages to scan
         */
        private List<String> entityPackages = Collections.singletonList("com.mlog.njyjy");

        /**
         * ddl auto
         */
        private Model2DdlAuto ddlAuto = Model2DdlAuto.none;

        /**
         * whether show sql
         */
        private boolean showSql = false;

        /**
         * dev mode or not, should be false(default) in production environment
         */
        private boolean devMode = false;


        public List<String> getEntityPackages() {
            return entityPackages;
        }

        public void setEntityPackages(List<String> entityPackages) {
            this.entityPackages = entityPackages;
        }

        public Model2DdlAuto getDdlAuto() {
            return ddlAuto;
        }

        public void setDdlAuto(Model2DdlAuto ddlAuto) {
            this.ddlAuto = ddlAuto;
        }

        public boolean isShowSql() {
            return showSql;
        }

        public void setShowSql(boolean showSql) {
            this.showSql = showSql;
        }

        public boolean isDevMode() {
            return devMode;
        }

        public void setDevMode(boolean devMode) {
            this.devMode = devMode;
        }
    }


    static class SqlDataSource {

        private String url;

        private String username;

        private String password;

        private String driverClassName;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getDriverClassName() {
            return driverClassName;
        }

        public void setDriverClassName(String driverClassName) {
            this.driverClassName = driverClassName;
        }
    }


}
